package drds.global_transaction.image.image_praser;

import drds.global_transaction.image.Image;
import drds.global_transaction.image.UndoLog;
import net.sf.jsqlparser.JSQLParserException;

import java.sql.SQLException;
import java.util.List;

public class UpdateImagePraser extends AbstractImagePraser
{

    UpdateImagePraser(String originalSql, UndoLog undoLog)
    {
        this.originalSql = originalSql;
        this.undoLog = undoLog;
    }


    @Override
    public String getTableName() throws JSQLParserException, SQLException
    {
        return SqlPraser.updateSentenceTableName(originalSql);
    }

    @Override
    public List<String> getColumnNameList() throws JSQLParserException
    {
        return SqlPraser.updateSentenceColumnNameList(originalSql);
    }

    @Override
    public String getWhereCondition() throws JSQLParserException
    {
        return SqlPraser.updateSentenceWhereCondition(originalSql);
    }

    //
    @Override
    public Image generateBeforeImage() throws SQLException, JSQLParserException
    {
        return getImage();
    }

    @Override
    public Image generateAfterImage() throws SQLException, JSQLParserException
    {
        return getImage();
    }


    @Override
    public String getBeforeOrAfterImageSql()
    {
        return imageSql;
    }
}
